﻿namespace PowerSong.Projection
    {
    using System;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Shapes;

    internal static class ControlFactory
        {

        internal static FrameworkElement CreateAssociatedControl(ProjectletType type)
            {

            switch (type)
                {

                case ProjectletType.Rectangle: return CreateRectangleControl();
                case ProjectletType.Image: return CreateImageControl();
                case ProjectletType.Text: return CreateTextControl();
                case ProjectletType.Video: return CreateVideoControl();

                default:
                    throw new Exception("Don't know how to create an associated projectlet control of type '" + type + "'.");

                }

            }

        private static FrameworkElement CreateRectangleControl()
            {
            return new Rectangle();
            }

        private static FrameworkElement CreateImageControl()
            {
            return new Image();
            }

        private static FrameworkElement CreateTextControl()
            {
            return new TextBlock();
            }

        private static FrameworkElement CreateVideoControl()
            {
            var control = new MediaElement();
            control.LoadedBehavior = MediaState.Manual;
            control.UnloadedBehavior = MediaState.Manual;
            return control;
            }

        }

    }
